﻿using System.IO;

namespace FxWinSuper.Plugin.Data
{
	/// <summary>
	/// 本地插件实体
	/// </summary>
	internal class LocalPluginEntity : RemotePluginEntity
	{
		/// <summary>
		/// 插件目录路径
		/// </summary>
		public string PluginPath { get; set; }

		/// <summary>
		/// 是否加载了该插件
		/// </summary>
		public bool Loaded { get; set; }

		/// <summary>
		/// 插件是否被禁用
		/// </summary>
		public bool Disabled { get; set; }

		internal static LocalPluginEntity FromPluginInfo(PluginInfo pluginInfo)
		{
			return new LocalPluginEntity()
			{
				Author = pluginInfo.PluginAssembleInfo.Author,
				Disabled = pluginInfo.Disabled,
				Loaded = pluginInfo.Loaded,
				PluginName = pluginInfo.PluginName,
				PluginPath = Path.GetDirectoryName(pluginInfo.PluginDllPath),
				Statement = pluginInfo.PluginAssembleInfo.Statement,
				Version = pluginInfo.PluginAssembleInfo.Version,
				VersionCode = pluginInfo.PluginAssembleInfo.VersionCode
			};
		}
	}
}
